﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Common.UI.Report.Views.Interfaces;
using Common.Model;

namespace Common.UI.Report.Views
{
    /// <summary>
    /// Interaction logic for ListView.xaml
    /// </summary>
    public partial class ListView : UserControl, IListView
    {

        Object _model;
        public Object Model
        {
            get
            {
                return _model;
            }
            set
            {
                _model = value;
                this.DataContext = _model;
            }
        }

        public ListView()
        {
            InitializeComponent();
        }

        #region IListView Members

        public void AddColumnDefinition(String columnName, String header)
        {
            var column = new DataGridTextColumn();

            column.Header = header;
            column.Binding = new Binding(columnName);
            column.IsReadOnly = true;
            this.listDataGrid.Columns.Add(column);
        }

        public void AddCustomCommand(Microsoft.Practices.Composite.Presentation.Commands.DelegateCommand<object> command, string text)
        {
            Button btn = new Button();
            btn.Content = text;
            btn.Command = command;

            this.extendedButtonsContainer.Children.Add(btn);
        }

        public void ShowReport(string reportPath, String dataSourceName, object data, List<ReportParameters> parameters, bool allowExport, bool allowPrint)
        {
            ReportWindow reportWindow = new ReportWindow(reportPath, dataSourceName, data, parameters, allowExport, allowPrint);
            reportWindow.ShowDialog();
        }

        #endregion

    }
}
